CREATE OR REPLACE PROCEDURE write_lob 
  (p_file IN VARCHAR2, p_dir IN VARCHAR2)
IS
 i    NUMBER;          v_fn VARCHAR2(15); 
 v_ln VARCHAR2(40);    v_b  BLOB;
BEGIN
  DBMS_OUTPUT.ENABLE;
  DBMS_OUTPUT.PUT_LINE('Begin inserting rows...');
  FOR i IN 1 .. 30 LOOP
    v_fn:=SUBSTR(p_file,1,INSTR(p_file,'.')-1);
    v_ln:=SUBSTR(p_file,INSTR(p_file,'.')+1,LENGTH(p_file)-
                 INSTR(p_file,'.')-4);
    INSERT INTO customer_profiles 
      VALUES (i, v_fn, v_ln, EMPTY_BLOB())
      RETURNING picture INTO v_b;
    loadLOBFromBFILE_proc(v_b,p_file, p_dir);
    DBMS_OUTPUT.PUT_LINE('Row '|| i ||' inserted.');
  END LOOP;
  COMMIT;
END write_lob;
/
